<template>
  <card :bordered="false" dis-hover>
    <div class="ivu-pt-8 ivu-mb-16">
      <Input v-width="300" v-model="input" placeholder="请输入搜索内容" @on-enter="searchWord(1)"></Input>
    </div>
    <Table :loading="loading" highlight-row :columns="columns" :data="list" border :max-height="550">
      <template slot="operation" slot-scope="{row}">
        <a @click="handleCopy(row.content)">
          复制
        </a>
      </template>
    </Table>
    <div class="ivu-mt ivu-text-center">
      <Page :current="page" :page-size="pageSize" @on-change="formSize" @on-page-size-change="formChangePage"
        :page-size-opts="pageOpts" :total="total" show-total show-elevator show-sizer />
    </div>
  </card>
</template>
<script>
  import { getWeChartList } from "../../api/TApi/index.js"
  export default {
    name: "fuzzyQuery",
    data() {
      return {
        input: "",
        loading: false,
        page: 1,
        pageSize: 15,
        total: 0,
        pageOpts: [10, 15, 20, 30, 50], // 分页每页数量
        list: [],
        columns: [
          {
            title: "关键词",
            key: "content",
            tooltip: true,

          },
          {
            title: "发送时间",
            key: "create_time",
          },
          {
            title: "微信昵称",
            key: "wechatnick",
            tooltip: true,
          },
          {
            title: "归属人",
            key: "weechtName",

          },
          {
            title: "复制",
            slot: "operation",
            width: 120,
          },
        ]
      }
    },
    methods: {
      /* @函数功能: 分页 */
      formSize(e) {
        this.page = e;
        this.searchWord(this.page);
      },
      /* @函数功能: 每页数量 */
      formChangePage(e) {
        this.pageSize = e;
        this.searchWord(this.page);
      },
      // 复制
      handleCopy(value) {
        this.$Copy({
          text: value
        })
      },
      searchWord(page) {
        if (this.input) {
          let params = {
            page,
            pageSize: this.pageSize,
            keyword: this.input
          }
          this.loading = true
          getWeChartList(params).then(res => {
            this.total = res.total
            this.list = res.list
          }).finally(() => {
            this.loading = false
          })
        } else {
          this.$Message.error('请输入搜索内容')
        }

      }
    }
  }
</script>